﻿using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Quartz;
using Quartz.AspNetCore;
using RuoVea.QuartzNetUI.Entitys;
using RuoVea.QuartzNetUI.Server;
using RuoVea.QuartzNetUI.Server.Impl;
using RuoVea.QuartzNetUI.Server.Scheduler;
using SqlSugar;
using System.Globalization;

namespace RuoVea.QuartzNetUI
{
    /// <summary>
    /// 注入扩展
    /// </summary>
    public static class TasksSetupExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="services"></param>
        /// <param name="config">配置节点{"DbType": "","ConnectionString": ""}
        ///"DbType": MySql、SqlServer、PostgreSQL、SQLite、Oracle、Firebird
        /// </param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="Exception"></exception>
        public static IServiceCollection AddQuartzNetServer(this IServiceCollection services, IConfiguration config)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
            if (config == null) throw new ArgumentNullException("请先添加 DbType、ConnectionString配置参数.");

            services.AddControllers().AddNewtonsoftJson(options =>
            {
                //options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                var dateConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter
                {
                    DateTimeFormat = "yyyy-MM-dd HH:MM:ss"
                };
                options.SerializerSettings.Converters.Add(dateConverter);
                //options.SerializerSettings.Culture = new CultureInfo("en-IE");
                options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
            });
            services.Configure<QuartzNetUIOptions>(config);
            // 注册 SqlSugar 的服务
            services.AddTransient<ISqlSugarClient>(provider =>
            {
                QuartzNetUIOptions databaseOptions = provider.GetService<IOptions<QuartzNetUIOptions>>()?.Value;
                return new SqlSugarClient(new ConnectionConfig
                {
                    IsAutoCloseConnection = true,
                    ConnectionString = databaseOptions.ConnectionString,
                    DbType = GetDbType(databaseOptions?.DbType)
                });
            });
            /***********Quartz.NET*********/
            services.AddQuartz(conf =>
            {
                conf.UseTimeZoneConverter();
                //// 使用MicrosoftDependencyInjectionJobFactory工厂类从 容器 中创建job实例
                //config.UseMicrosoftDependencyInjectionJobFactory(options =>
                //{
                //    options.AllowDefaultConstructor = false;    // 禁止使用无参构建函数创建 job
                //    options.CreateScope = false;
                //});

                conf.UseDefaultThreadPool(options =>
                {
                    options.MaxConcurrency = 10;    // 最大并发执行线程数
                });
                conf.UsePersistentStore(options =>
                {
                    options.UseProperties = false;
                    //options.UseBinarySerializer();  // 二进制序列化
                    options.UseJsonSerializer();    // json序列化
                    options.PerformSchemaValidation = false;
                    DbType dbType = GetDbType(config.GetSection("DbType")?.Value);
                    if (dbType == DbType.MySql)
                    {
                        options.UseMySql(ado =>
                        {
                            ado.ConnectionString = config.GetSection("ConnectionString")?.Value;
                            ado.TablePrefix = "Qrtz_";  // 默认值 QRTZ_
                            ado.ConnectionStringName = "Quartz.net";
                        });
                    }
                    else if (dbType == DbType.SqlServer)
                    {
                        options.UseSqlServer(ado =>
                        {
                            ado.ConnectionString = config.GetSection("ConnectionString")?.Value;
                            ado.TablePrefix = "Qrtz_";  // 默认值 QRTZ_
                            ado.ConnectionStringName = "Quartz.net";
                        });
                    }
                    else if (dbType == DbType.PostgreSQL)
                    {
                        options.UsePostgres(ado =>
                        {
                            ado.ConnectionString = config.GetSection("ConnectionString")?.Value;
                            ado.TablePrefix = "Qrtz_";  // 默认值 QRTZ_
                            ado.ConnectionStringName = "Quartz.net";
                        });
                    }
                    else if (dbType == DbType.Oracle)
                    {
                        options.UseOracle(ado =>
                        {
                            ado.ConnectionString = config.GetSection("ConnectionString")?.Value;
                            ado.TablePrefix = "Qrtz_";  // 默认值 QRTZ_
                            ado.ConnectionStringName = "Quartz.net";
                        });
                    }
                    else
                    {
                        options.UseSQLite(ado =>
                        {
                            ado.ConnectionString = config.GetSection("ConnectionString")?.Value;
                            ado.TablePrefix = "Qrtz_";  // 默认值 QRTZ_
                            ado.ConnectionStringName = "Quartz.net";
                        });
                    }
                });
            });
            // IHostedService宿主启动 Quartz服务 services.AddSingleton<IHostedService, QuartzHostedService>()
            services.AddQuartzServer(options =>
            {
                // when shutting down we want jobs to complete gracefully
                options.WaitForJobsToComplete = true;   // 等待任务执行完，再退出
            });

            services.TryAddTransient<ITaskSchedulerServer, TaskSchedulerServer>();
            services.TryAddTransient<ITaskLogService, TaskLogService>();
            services.TryAddTransient<ITaskDetailService, TaskDetailService>();
            services.AddControllersWithViews().AddRazorRuntimeCompilation(option =>
            {
                option.FileProviders.Add(new EmbeddedFileProvider(typeof(RuoVea.QuartzNetUI.Controllers.QuartzJobController).GetTypeInfo().Assembly));
            });
            return services;
        }
        private static DbType GetDbType(string dbType)
        {
            if (string.IsNullOrEmpty(dbType))
                throw new ArgumentNullException("Not Assist Firebird Database");
            switch (dbType.ToUpper())
            {
                case "MYSQL": return DbType.MySql;
                case "SQLSERVER": return DbType.SqlServer;
                case "POSTGRESQL": return DbType.PostgreSQL;
                case "SQLITE": return DbType.Sqlite;
                case "ORACLE": return DbType.Oracle;
                case "FIREBIRD":
                    throw new ArgumentNullException("Not Assist Firebird Database");
                default:
                    throw new ArgumentNullException("dbProviderName unreasonable");
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseQuartzUI(this IApplicationBuilder app)
        {
            ISqlSugarClient db = app.ApplicationServices.GetRequiredService<ISqlSugarClient>();

            if (!db.DbMaintenance.IsAnyTable("Qrtz_Task_Log"))
                db.CodeFirst.InitTables<TaskLog>();

            if (!db.DbMaintenance.IsAnyTable("Qrtz_Task_Detail"))
                db.CodeFirst.InitTables<TaskDetail>();

            if (!db.DbMaintenance.IsAnyTable("Qrtz_Task_Setting"))
                db.CodeFirst.InitTables<TaskSetting>();
            #region .
            ////if (!db.DbMaintenance.IsAnyTable("Qrtz_Task_Details"))
            //{
            //    bool createDatabase = db.DbMaintenance.CreateDatabase();
            //    //db.CodeFirst.As<BlobTriggers>("Qrtz_Blob_Triggers").InitTables<BlobTriggers>();
            //    //db.CodeFirst.As<Calendars>("Qrtz_Calendars").InitTables<Calendars>();
            //    //db.CodeFirst.As<CronTriggers>("Qrtz_Cron_Triggers").InitTables<CronTriggers>();
            //    //db.CodeFirst.As<FiredTriggers>("Qrtz_Fired_Triggers").InitTables<FiredTriggers>();
            //    //db.CodeFirst.As<JobDetails>("Qrtz_Job_Details").InitTables<JobDetails>();
            //    //db.CodeFirst.As<Locks>("Qrtz_Locks").InitTables<Locks>();
            //    //db.CodeFirst.As<PausedTriggerGrps>("Qrtz_Paused_Trigger_Grps").InitTables<PausedTriggerGrps>();
            //    //db.CodeFirst.As<SchedulerState>("Qrtz_Scheduler_State").InitTables<SchedulerState>();
            //    //db.CodeFirst.As<SimpleTriggers>("Qrtz_Simple_Triggers").InitTables<SimpleTriggers>();
            //    //db.CodeFirst.As<SimpropTriggers>("Qrtz_Simprop_Triggers").InitTables<SimpropTriggers>();
            //    //db.CodeFirst.As<Triggers>("Qrtz_Triggers").InitTables<Triggers>();
            //    if (createDatabase)
            //    {
            //        db.CodeFirst.InitTables<TaskLog>();
            //        db.CodeFirst.InitTables<TaskDetail>();
            //        db.CodeFirst.InitTables<TaskSetting>();
            //        //QuartzNetUIOptions quartzOption = app.ApplicationServices.GetService<IOptions<QuartzNetUIOptions>>().Value;
            //        //db.Ado.ExecuteCommandAsync(SqlComment(quartzOption.DbType.ToLower()));
            //    }
            //} 
            #endregion

            ITaskSchedulerServer _schedulerServer = app.ApplicationServices.GetRequiredService<ITaskSchedulerServer>();
            ITaskDetailService _taskDetailService = app.ApplicationServices.GetRequiredService<ITaskDetailService>();
            db = app.ApplicationServices.GetRequiredService<ISqlSugarClient>();
            List<TaskDetail> tasks = db.Queryable<TaskDetail>().Where(x => x.Deleted == ExEnum.IsDelete.N && x.Status == ExEnum.StatusEnum.ENABLE).ToList();
            foreach (var task in tasks)
            {
                var model = _taskDetailService.DetailToInDto(task);
                if (!_schedulerServer.CheckExists(model))
                    _schedulerServer.AddTaskScheduleAsync(model);
            }
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new EmbeddedFileProvider(typeof(RuoVea.QuartzNetUI.Controllers.QuartzJobController).GetTypeInfo().Assembly)
            });

            return app;
        }

        private static string SqlComment(string key)
        {
            string mysql = "# by: ron cordell - roncordell\r\n#  i didn't see this anywhere, so i thought i'd post it here. this is the script from quartz to create the tables in a mysql database, modified to use innodb instead of myisam.\r\n\r\n\r\n# make sure you have utf-8 collaction for best .net interoperability\r\n# create database quartznet character set utf8mb4 collate utf8mb4_unicode_ci;\r\n\r\ndrop table if exists Qrtz_Fired_Triggers;\r\ndrop table if exists Qrtz_Paused_Trigger_Grps;\r\ndrop table if exists Qrtz_Scheduler_State;\r\ndrop table if exists Qrtz_Locks;\r\ndrop table if exists Qrtz_Simple_Triggers;\r\ndrop table if exists Qrtz_Simprop_Triggers;\r\ndrop table if exists Qrtz_Cron_Triggers;\r\ndrop table if exists Qrtz_Blob_Triggers;\r\ndrop table if exists Qrtz_Triggers;\r\ndrop table if exists Qrtz_Job_Details;\r\ndrop table if exists Qrtz_Calendars;\r\n\r\ncreate table Qrtz_Job_Details(\r\nSched_Name varchar(120) not null,\r\nJob_Name varchar(200) not null,\r\nJob_Group varchar(200) not null,\r\nDescription varchar(250) null,\r\nJob_Class_Name varchar(250) not null,\r\nIs_Durable boolean not null,\r\nIs_Nonconcurrent boolean not null,\r\nIs_Update_Data boolean not null,\r\nRequests_Recovery boolean not null,\r\nJob_Data blob null,\r\nprimary key (Sched_Name,Job_Name,Job_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Triggers (\r\nSched_Name varchar(120) not null,\r\nTrigger_Name varchar(200) not null,\r\nTrigger_Group varchar(200) not null,\r\nJob_Name varchar(200) not null,\r\nJob_Group varchar(200) not null,\r\nDescription varchar(250) null,\r\nNext_Fire_Time bigint(19) null,\r\nPrev_Fire_Time bigint(19) null,\r\nPriority integer null,\r\nTrigger_State varchar(16) not null,\r\nTrigger_Type varchar(8) not null,\r\nStart_Time bigint(19) not null,\r\nEnd_Time bigint(19) null,\r\nCalendar_Name varchar(200) null,\r\nMisfire_Instr smallint(2) null,\r\nJob_Data blob null,\r\nprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\nforeign key (Sched_Name,Job_Name,Job_Group)\r\nreferences Qrtz_Job_Details(Sched_Name,Job_Name,Job_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Simple_Triggers (\r\nSched_Name varchar(120) not null,\r\nTrigger_Name varchar(200) not null,\r\nTrigger_Group varchar(200) not null,\r\nRepeat_Count bigint(7) not null,\r\nRepeat_Interval bigint(12) not null,\r\nTimes_Triggered bigint(10) not null,\r\nprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\nforeign key (Sched_Name,Trigger_Name,Trigger_Group)\r\nreferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Cron_Triggers (\r\nSched_Name varchar(120) not null,\r\nTrigger_Name varchar(200) not null,\r\nTrigger_Group varchar(200) not null,\r\nCron_Expression varchar(120) not null,\r\nTime_Zone_Id varchar(80),\r\nprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\nforeign key (Sched_Name,Trigger_Name,Trigger_Group)\r\nreferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Simprop_Triggers\r\n  (          \r\n    Sched_Name varchar(120) not null,\r\n    Trigger_Name varchar(200) not null,\r\n    Trigger_Group varchar(200) not null,\r\n    Str_Prop_1 varchar(512) null,\r\n    Str_Prop_2 varchar(512) null,\r\n    Str_Prop_3 varchar(512) null,\r\n    Int_Prop_1 int null,\r\n    Int_Prop_2 int null,\r\n    Long_Prop_1 bigint null,\r\n    Long_Prop_2 bigint null,\r\n    Dec_Prop_1 numeric(13,4) null,\r\n    Dec_Prop_2 numeric(13,4) null,\r\n    Bool_Prop_1 boolean null,\r\n    Bool_Prop_2 boolean null,\r\n    Time_Zone_Id varchar(80) null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n    references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Blob_Triggers (\r\nSched_Name varchar(120) not null,\r\nTrigger_Name varchar(200) not null,\r\nTrigger_Group varchar(200) not null,\r\nBlob_Data blob null,\r\nprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\nindex (Sched_Name,Trigger_Name, Trigger_Group),\r\nforeign key (Sched_Name,Trigger_Name,Trigger_Group)\r\nreferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Calendars (\r\nSched_Name varchar(120) not null,\r\nCalendar_Name varchar(200) not null,\r\nCalendar blob not null,\r\nprimary key (Sched_Name,Calendar_Name))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Paused_Trigger_Grps (\r\nSched_Name varchar(120) not null,\r\nTrigger_Group varchar(200) not null,\r\nprimary key (Sched_Name,Trigger_Group))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Fired_Triggers (\r\nSched_Name varchar(120) not null,\r\nentry_id varchar(140) not null,\r\nTrigger_Name varchar(200) not null,\r\nTrigger_Group varchar(200) not null,\r\nInstance_Name varchar(200) not null,\r\nFired_Time bigint(19) not null,\r\nSched_Time bigint(19) not null,\r\nPriority integer not null,\r\nState varchar(16) not null,\r\nJob_Name varchar(200) null,\r\nJob_Group varchar(200) null,\r\nIs_Nonconcurrent boolean null,\r\nRequests_Recovery boolean null,\r\nprimary key (Sched_Name,entry_id))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Scheduler_State (\r\nSched_Name varchar(120) not null,\r\nInstance_Name varchar(200) not null,\r\nLast_Checkin_Time bigint(19) not null,\r\nCheckin_Interval bigint(19) not null,\r\nprimary key (Sched_Name,Instance_Name))\r\nengine=innodb;\r\n\r\ncreate table Qrtz_Locks (\r\nSched_Name varchar(120) not null,\r\nLock_Name varchar(40) not null,\r\nprimary key (Sched_Name,Lock_Name))\r\nengine=innodb;\r\n\r\ncreate index idx_qrtz_j_req_recovery on Qrtz_Job_Details(Sched_Name,Requests_Recovery);\r\ncreate index idx_qrtz_j_grp on Qrtz_Job_Details(Sched_Name,Job_Group);\r\n\r\ncreate index idx_qrtz_t_j on Qrtz_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_t_jg on Qrtz_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_t_c on Qrtz_Triggers(Sched_Name,Calendar_Name);\r\ncreate index idx_qrtz_t_g on Qrtz_Triggers(Sched_Name,Trigger_Group);\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Sched_Name,Trigger_State);\r\ncreate index idx_qrtz_t_n_state on Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_n_g_state on Qrtz_Triggers(Sched_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Sched_Name,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Sched_Name,Trigger_State,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_State);\r\ncreate index idx_qrtz_t_nft_st_misfire_grp on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_Group,Trigger_State);\r\n\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Sched_Name,Instance_Name);\r\ncreate index idx_qrtz_ft_inst_job_req_rcvry on Qrtz_Fired_Triggers(Sched_Name,Instance_Name,Requests_Recovery);\r\ncreate index idx_qrtz_ft_j_g on Qrtz_Fired_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_ft_jg on Qrtz_Fired_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_ft_t_g on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group);\r\ncreate index idx_qrtz_ft_tg on Qrtz_Fired_Triggers(Sched_Name,Trigger_Group);\r\n\r\ncommit; \r\n";
            string sqlite = "drop table if exists Qrtz_Fired_Triggers;\r\ndrop table if exists Qrtz_Paused_Trigger_Grps;\r\ndrop table if exists Qrtz_Scheduler_State;\r\ndrop table if exists Qrtz_Locks;\r\ndrop table if exists Qrtz_Simprop_Triggers;\r\ndrop table if exists Qrtz_Simple_Triggers;\r\ndrop table if exists Qrtz_Cron_Triggers;\r\ndrop table if exists Qrtz_Blob_Triggers;\r\ndrop table if exists Qrtz_Triggers;\r\ndrop table if exists Qrtz_Job_Details;\r\ndrop table if exists Qrtz_Calendars;\r\n\r\n\r\ncreate table Qrtz_Job_Details\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tJob_Name nvarchar(150) not null,\r\n    Job_Group nvarchar(150) not null,\r\n    Description nvarchar(250) null,\r\n    Job_Class_Name   nvarchar(250) not null,\r\n    Is_Durable bit not null,\r\n    Is_Nonconcurrent bit not null,\r\n    Is_Update_Data bit  not null,\r\n\tRequests_Recovery bit not null,\r\n    Job_Data blob null,\r\n    primary key (Sched_Name,Job_Name,Job_Group)\r\n);\r\n\r\ncreate table Qrtz_Triggers\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tTrigger_Name nvarchar(150) not null,\r\n    Trigger_Group nvarchar(150) not null,\r\n    Job_Name nvarchar(150) not null,\r\n    Job_Group nvarchar(150) not null,\r\n    Description nvarchar(250) null,\r\n    Next_Fire_Time bigint null,\r\n    Prev_Fire_Time bigint null,\r\n    Priority integer null,\r\n    Trigger_State nvarchar(16) not null,\r\n    Trigger_Type nvarchar(8) not null,\r\n    Start_Time bigint not null,\r\n    End_Time bigint null,\r\n    Calendar_Name nvarchar(200) null,\r\n    Misfire_Instr integer null,\r\n    Job_Data blob null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Job_Name,Job_Group)\r\n        references Qrtz_Job_Details(Sched_Name,Job_Name,Job_Group)\r\n);\r\n\r\ncreate table Qrtz_Simple_Triggers\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tTrigger_Name nvarchar(150) not null,\r\n    Trigger_Group nvarchar(150) not null,\r\n    Repeat_Count bigint not null,\r\n    Repeat_Interval bigint not null,\r\n    Times_Triggered bigint not null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group)\r\n        references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate trigger delete_simple_trigger delete on Qrtz_Triggers\r\nbegin\r\n\tdelete from Qrtz_Simple_Triggers where Sched_Name=old.Sched_Name and Trigger_Name=old.Trigger_Name and Trigger_Group=old.Trigger_Group;\r\nend\r\n;\r\n\r\ncreate table Qrtz_Simprop_Triggers \r\n  (\r\n    Sched_Name nvarchar (120) not null ,\r\n    Trigger_Name nvarchar (150) not null ,\r\n    Trigger_Group nvarchar (150) not null ,\r\n    Str_Prop_1 nvarchar (512) null,\r\n    Str_Prop_2 nvarchar (512) null,\r\n    Str_Prop_3 nvarchar (512) null,\r\n    Int_Prop_1 int null,\r\n    Int_Prop_2 int null,\r\n    Long_Prop_1 bigint null,\r\n    Long_Prop_2 bigint null,\r\n    Dec_Prop_1 numeric null,\r\n    Dec_Prop_2 numeric null,\r\n    Bool_Prop_1 bit null,\r\n    Bool_Prop_2 bit null,\r\n    Time_Zone_Id nvarchar(80) null,\r\n\tprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n\tforeign key (Sched_Name,Trigger_Name,Trigger_Group)\r\n        references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate trigger delete_simprop_trigger delete on Qrtz_Triggers\r\nbegin\r\n\tdelete from Qrtz_Simprop_Triggers where Sched_Name=old.Sched_Name and Trigger_Name=old.Trigger_Name and Trigger_Group=old.Trigger_Group;\r\nend\r\n;\r\n\r\ncreate table Qrtz_Cron_Triggers\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tTrigger_Name nvarchar(150) not null,\r\n    Trigger_Group nvarchar(150) not null,\r\n    Cron_Expression nvarchar(250) not null,\r\n    Time_Zone_Id nvarchar(80),\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group)\r\n        references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate trigger delete_cron_trigger delete on Qrtz_Triggers\r\nbegin\r\n\tdelete from Qrtz_Cron_Triggers where Sched_Name=old.Sched_Name and Trigger_Name=old.Trigger_Name and Trigger_Group=old.Trigger_Group;\r\nend\r\n;\r\n\r\ncreate table Qrtz_Blob_Triggers\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tTrigger_Name nvarchar(150) not null,\r\n    Trigger_Group nvarchar(150) not null,\r\n    Blob_Data blob null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group)\r\n        references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate trigger delete_blob_trigger delete on Qrtz_Triggers\r\nbegin\r\n\tdelete from Qrtz_Blob_Triggers where Sched_Name=old.Sched_Name and Trigger_Name=old.Trigger_Name and Trigger_Group=old.Trigger_Group;\r\nend\r\n;\r\n\r\ncreate table Qrtz_Calendars\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tCalendar_Name  nvarchar(200) not null,\r\n    Calendar blob not null,\r\n    primary key (Sched_Name,Calendar_Name)\r\n);\r\n\r\ncreate table Qrtz_Paused_Trigger_Grps\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tTrigger_Group nvarchar(150) not null, \r\n    primary key (Sched_Name,Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Fired_Triggers\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tentry_id nvarchar(140) not null,\r\n    Trigger_Name nvarchar(150) not null,\r\n    Trigger_Group nvarchar(150) not null,\r\n    Instance_Name nvarchar(200) not null,\r\n    Fired_Time bigint not null,\r\n    Sched_Time bigint not null,\r\n\tPriority integer not null,\r\n    State nvarchar(16) not null,\r\n    Job_Name nvarchar(150) null,\r\n    Job_Group nvarchar(150) null,\r\n    Is_Nonconcurrent bit null,\r\n    Requests_Recovery bit null,\r\n    primary key (Sched_Name,entry_id)\r\n);\r\n\r\ncreate table Qrtz_Scheduler_State\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tInstance_Name nvarchar(200) not null,\r\n    Last_Checkin_Time bigint not null,\r\n    Checkin_Interval bigint not null,\r\n    primary key (Sched_Name,Instance_Name)\r\n);\r\n\r\ncreate table Qrtz_Locks\r\n  (\r\n    Sched_Name nvarchar(120) not null,\r\n\tLock_Name  nvarchar(40) not null, \r\n    primary key (Sched_Name,Lock_Name)\r\n);\r\n";
            string postgres = "drop table if exists Qrtz_Fired_Triggers;\r\ndrop table if exists Qrtz_Paused_Trigger_Grps;\r\ndrop table if exists Qrtz_Scheduler_State;\r\ndrop table if exists Qrtz_Locks;\r\ndrop table if exists Qrtz_Simprop_Triggers;\r\ndrop table if exists Qrtz_Simple_Triggers;\r\ndrop table if exists Qrtz_Cron_Triggers;\r\ndrop table if exists Qrtz_Blob_Triggers;\r\ndrop table if exists Qrtz_Triggers;\r\ndrop table if exists Qrtz_Job_Details;\r\ndrop table if exists Qrtz_Calendars;\r\n\r\n\r\ncreate table Qrtz_Job_Details\r\n  (\r\n    Sched_Name varchar(120) not null,\r\n\tJob_Name  varchar(200) not null,\r\n    Job_Group varchar(200) not null,\r\n    Description varchar(250) null,\r\n    Job_Class_Name   varchar(250) not null, \r\n    Is_Durable bool not null,\r\n    Is_Nonconcurrent bool not null,\r\n    Is_Update_Data bool not null,\r\n\tRequests_Recovery bool not null,\r\n    Job_Data bytea null,\r\n    primary key (Sched_Name,Job_Name,Job_Group)\r\n);\r\n\r\ncreate table Qrtz_Triggers\r\n  (\r\n    Sched_Name varchar(120) not null,\r\n\tTrigger_Name varchar(150) not null,\r\n    Trigger_Group varchar(150) not null,\r\n    Job_Name  varchar(200) not null, \r\n    Job_Group varchar(200) not null,\r\n    Description varchar(250) null,\r\n    Next_Fire_Time bigint null,\r\n    Prev_Fire_Time bigint null,\r\n    Priority integer null,\r\n    Trigger_State varchar(16) not null,\r\n    Trigger_Type varchar(8) not null,\r\n    Start_Time bigint not null,\r\n    End_Time bigint null,\r\n    Calendar_Name varchar(200) null,\r\n    Misfire_Instr smallint null,\r\n    Job_Data bytea null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Job_Name,Job_Group) \r\n\t\treferences Qrtz_Job_Details(Sched_Name,Job_Name,Job_Group) \r\n);\r\n\r\ncreate table Qrtz_Simple_Triggers\r\n  (\r\n    Sched_Name varchar(120) not null,\r\n\tTrigger_Name varchar(150) not null,\r\n    Trigger_Group varchar(150) not null,\r\n    Repeat_Count bigint not null,\r\n    Repeat_Interval bigint not null,\r\n    Times_Triggered bigint not null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n\t\treferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate table Qrtz_Simprop_Triggers \r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Trigger_Name varchar (150) not null ,\r\n    Trigger_Group varchar (150) not null ,\r\n    Str_Prop_1 varchar (512) null,\r\n    Str_Prop_2 varchar (512) null,\r\n    Str_Prop_3 varchar (512) null,\r\n    Int_Prop_1 integer null,\r\n    Int_Prop_2 integer null,\r\n    Long_Prop_1 bigint null,\r\n    Long_Prop_2 bigint null,\r\n    Dec_Prop_1 numeric null,\r\n    Dec_Prop_2 numeric null,\r\n    Bool_Prop_1 bool null,\r\n    Bool_Prop_2 bool null,\r\n\tTime_Zone_Id varchar(80) null,\r\n\tprimary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n\t\treferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate table Qrtz_Cron_Triggers\r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Trigger_Name varchar(150) not null,\r\n    Trigger_Group varchar(150) not null,\r\n    Cron_Expression varchar(250) not null,\r\n    Time_Zone_Id varchar(80),\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n\t\treferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate table Qrtz_Blob_Triggers\r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Trigger_Name varchar(150) not null,\r\n    Trigger_Group varchar(150) not null,\r\n    Blob_Data bytea null,\r\n    primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n\t\treferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group) on delete cascade\r\n);\r\n\r\ncreate table Qrtz_Calendars\r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Calendar_Name  varchar(200) not null, \r\n    Calendar bytea not null,\r\n    primary key (Sched_Name,Calendar_Name)\r\n);\r\n\r\ncreate table Qrtz_Paused_Trigger_Grps\r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Trigger_Group varchar(150) not null, \r\n    primary key (Sched_Name,Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Fired_Triggers \r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    entry_id varchar(140) not null,\r\n    Trigger_Name varchar(150) not null,\r\n    Trigger_Group varchar(150) not null,\r\n    Instance_Name varchar(200) not null,\r\n    Fired_Time bigint not null,\r\n\tSched_Time bigint not null,\r\n    Priority integer not null,\r\n    State varchar(16) not null,\r\n    Job_Name varchar(200) null,\r\n    Job_Group varchar(200) null,\r\n    Is_Nonconcurrent bool not null,\r\n    Requests_Recovery bool null,\r\n    primary key (Sched_Name,entry_id)\r\n);\r\n\r\ncreate table Qrtz_Scheduler_State \r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Instance_Name varchar(200) not null,\r\n    Last_Checkin_Time bigint not null,\r\n    Checkin_Interval bigint not null,\r\n    primary key (Sched_Name,Instance_Name)\r\n);\r\n\r\ncreate table Qrtz_Locks\r\n  (\r\n    Sched_Name varchar (120) not null,\r\n    Lock_Name  varchar(40) not null, \r\n    primary key (Sched_Name,Lock_Name)\r\n);\r\n\r\ncreate index idx_qrtz_j_req_recovery on Qrtz_Job_Details(Requests_Recovery);\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Next_Fire_Time);\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Trigger_State);\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Next_Fire_Time,Trigger_State);\r\ncreate index idx_qrtz_ft_trig_name on Qrtz_Fired_Triggers(Trigger_Name);\r\ncreate index idx_qrtz_ft_trig_group on Qrtz_Fired_Triggers(Trigger_Group);\r\ncreate index idx_qrtz_ft_trig_nm_gp on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group);\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Instance_Name);\r\ncreate index idx_qrtz_ft_Job_Name on Qrtz_Fired_Triggers(Job_Name);\r\ncreate index idx_qrtz_ft_Job_Group on Qrtz_Fired_Triggers(Job_Group);\r\ncreate index idx_qrtz_ft_job_req_recovery on Qrtz_Fired_Triggers(Requests_Recovery);";
            string firebird = "-- this script is for firebird\r\n-- firebird db script submitted by leonardo alves and tweaked by siyu wu\r\n\r\ndrop table Qrtz_Fired_Triggers;\r\ndrop table Qrtz_Paused_Trigger_Grps;\r\ndrop table Qrtz_Scheduler_State;\r\ndrop table Qrtz_Locks;\r\ndrop table Qrtz_Simple_Triggers;\r\ndrop table Qrtz_Simprop_Triggers;\r\ndrop table Qrtz_Cron_Triggers;\r\ndrop table Qrtz_Blob_Triggers;\r\ndrop table Qrtz_Triggers;\r\ndrop table Qrtz_Job_Details;\r\ndrop table Qrtz_Calendars;\r\n\r\n\r\ncreate table Qrtz_Job_Details (\r\n    Sched_Name         varchar(120) not null,\r\n    Job_Name           varchar(150) not null,\r\n    Job_Group          varchar(150) not null,\r\n    Description        varchar(250) default null,\r\n    Job_Class_Name     varchar(250) not null,\r\n    Is_Durable         smallint not null,\r\n    Is_Nonconcurrent   smallint not null,\r\n    Is_Update_Data     smallint not null,\r\n    Requests_Recovery  smallint not null,\r\n    Job_Data           blob default null,\r\n    constraint pk_Qrtz_Job_Details primary key (Sched_Name,Job_Name,Job_Group)\r\n);\r\n\r\ncreate table Qrtz_Triggers (\r\n    Sched_Name      varchar(120) not null,\r\n    Trigger_Name    varchar(150) not null,\r\n    Trigger_Group   varchar(150) not null,\r\n    Job_Name        varchar(150) not null,\r\n    Job_Group       varchar(150) not null,\r\n    Description     varchar(250) default null,\r\n    Next_Fire_Time  bigint default null,\r\n    Prev_Fire_Time  bigint default null,\r\n    Priority        integer default null,\r\n    Trigger_State   varchar(16) not null,\r\n    Trigger_Type    varchar(8) not null,\r\n    Start_Time      bigint not null,\r\n    End_Time        bigint default null,\r\n    Calendar_Name   varchar(200) default null,\r\n    Misfire_Instr   smallint default null,\r\n    Job_Data        blob default null,\r\n    constraint pk_Qrtz_Triggers primary key (Sched_Name, Trigger_Name, Trigger_Group),\r\n    constraint fk_Qrtz_Triggers_1 foreign key (Sched_Name, Job_Name, Job_Group)\r\n    references Qrtz_Job_Details(Sched_Name, Job_Name, Job_Group)\r\n);\r\n\r\ncreate table Qrtz_Simple_Triggers (\r\n    Sched_Name       varchar(120) not null,\r\n    Trigger_Name     varchar(150) not null,\r\n    Trigger_Group    varchar(150) not null,\r\n    Repeat_Count     bigint not null,\r\n    Repeat_Interval  bigint not null,\r\n    Times_Triggered  bigint not null,\r\n    constraint pk_Qrtz_Simple_Triggers primary key (Sched_Name, Trigger_Name, Trigger_Group),\r\n    constraint fk_Qrtz_Simple_Triggers_1 foreign key (Sched_Name, Trigger_Name, Trigger_Group)\r\n    references Qrtz_Triggers(Sched_Name, Trigger_Name, Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Cron_Triggers (\r\n    Sched_Name       varchar(120) not null,\r\n    Trigger_Name     varchar(150) not null,\r\n    Trigger_Group    varchar(150) not null,\r\n    Cron_Expression  varchar(250) not null,\r\n    Time_Zone_Id     varchar(80),\r\n    constraint pk_Qrtz_Cron_Triggers primary key (Sched_Name, Trigger_Name, Trigger_Group),\r\n    constraint fk_Qrtz_Cron_Triggers_1 foreign key (Sched_Name, Trigger_Name, Trigger_Group)\r\n    references Qrtz_Triggers(Sched_Name, Trigger_Name,Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Simprop_Triggers (\r\n    Sched_Name     varchar(120) not null,\r\n    Trigger_Name   varchar(150) not null,\r\n    Trigger_Group  varchar(150) not null,\r\n    Str_Prop_1     varchar(512) default null,\r\n    Str_Prop_2     varchar(512) default null,\r\n    Str_Prop_3     varchar(512) default null,\r\n    Int_Prop_1     integer default null,\r\n    Int_Prop_2     integer default null,\r\n    Long_Prop_1    bigint default null,\r\n    Long_Prop_2    bigint default null,\r\n    Dec_Prop_1     numeric(9,0) default  null,\r\n    Dec_Prop_2     numeric(9,0) default null,\r\n    Bool_Prop_1    smallint default null,\r\n    Bool_Prop_2    smallint default null,\r\n    Time_Zone_Id   varchar(80) default null,\r\n    constraint pk_Qrtz_Simprop_Triggers primary key (Sched_Name, Trigger_Name, Trigger_Group),\r\n    constraint fk_Qrtz_Simprop_Triggers_1 foreign key (Sched_Name, Trigger_Name, Trigger_Group)\r\n    references Qrtz_Triggers(Sched_Name, Trigger_Name,Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Blob_Triggers (\r\n    Sched_Name     varchar(120) not null,\r\n    Trigger_Name   varchar(150) not null,\r\n    Trigger_Group  varchar(150) not null,\r\n    Blob_Data      blob default null,\r\n    constraint pk_Qrtz_Blob_Triggers primary key (Sched_Name, Trigger_Name,Trigger_Group),\r\n    constraint fk_Qrtz_Blob_Triggers_1 foreign key (Sched_Name, Trigger_Name,Trigger_Group)\r\n    references Qrtz_Triggers(Sched_Name, Trigger_Name,Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Calendars (\r\n    Sched_Name     varchar(120) not null,\r\n    Calendar_Name  varchar(200) not null,\r\n    Calendar       blob not null,\r\n    constraint pk_Qrtz_Calendars primary key (Sched_Name, Calendar_Name)\r\n);\r\n\r\ncreate table Qrtz_Paused_Trigger_Grps (\r\n    Sched_Name     varchar(120) not null,\r\n    Trigger_Group  varchar(150) not null,\r\n    constraint pk_Qrtz_Paused_Trigger_Grps primary key (Sched_Name, Trigger_Group)\r\n);\r\n\r\ncreate table Qrtz_Fired_Triggers (\r\n    Sched_Name         varchar(120) not null,\r\n    entry_id           varchar(140) not null,\r\n    Trigger_Name       varchar(150) not null,\r\n    Trigger_Group      varchar(150) not null,\r\n    Instance_Name      varchar(200) not null,\r\n    Fired_Time         bigint not null,\r\n    Sched_Time         bigint not null,\r\n    Priority           integer not null,\r\n    State              varchar(16) not null,\r\n    Job_Name           varchar(150) default null,\r\n    Job_Group          varchar(150) default null,\r\n    Is_Nonconcurrent   smallint not null,\r\n    Requests_Recovery  smallint default null,\r\n    constraint pk_Qrtz_Fired_Triggers primary key (Sched_Name, entry_id)\r\n);\r\n\r\ncreate table Qrtz_Scheduler_State (\r\n    Sched_Name         varchar(120) not null,\r\n    Instance_Name      varchar(200) not null,\r\n    Last_Checkin_Time  bigint not null,\r\n    Checkin_Interval   bigint not null,\r\n    constraint pk_Qrtz_Scheduler_State primary key (Sched_Name, Instance_Name)\r\n);\r\n\r\ncreate table Qrtz_Locks (\r\n    Sched_Name  varchar(120) not null,\r\n    Lock_Name   varchar(40) not null,\r\n    constraint pk_Qrtz_Locks primary key (Sched_Name, Lock_Name)\r\n);\r\n\r\ncreate index idx_qrtz_j_req_recovery on Qrtz_Job_Details(Sched_Name,Requests_Recovery);\r\ncreate index idx_qrtz_j_grp on Qrtz_Job_Details(Sched_Name,Job_Group);\r\n\r\ncreate index idx_qrtz_t_j on Qrtz_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_t_jg on Qrtz_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_t_c on Qrtz_Triggers(Sched_Name,Calendar_Name);\r\ncreate index idx_qrtz_t_g on Qrtz_Triggers(Sched_Name,Trigger_Group);\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Sched_Name,Trigger_State);\r\ncreate index idx_qrtz_t_n_state on Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_n_g_state on Qrtz_Triggers(Sched_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Sched_Name,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Sched_Name,Trigger_State,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_State);\r\ncreate index idx_qrtz_t_nft_st_misfire_grp on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_Group,Trigger_State);\r\n\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Sched_Name,Instance_Name);\r\ncreate index idx_qrtz_ft_inst_job_req_rcvry on Qrtz_Fired_Triggers(Sched_Name,Instance_Name,Requests_Recovery);\r\ncreate index idx_qrtz_ft_j_g on Qrtz_Fired_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_ft_jg on Qrtz_Fired_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_ft_t_g on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group);\r\ncreate index idx_qrtz_ft_tg on Qrtz_Fired_Triggers(Sched_Name,Trigger_Group);\r\n\r\ncommit;\r\n";
            string oracle = "--\r\n-- a hint submitted by a user: oracle db must be created as \"shared\" and the \r\n-- job_queue_processes parameter  must be greater than 2\r\n-- however, these settings are pretty much standard after any\r\n-- oracle install, so most users need not worry about this.\r\n--\r\n-- many other users (including the primary author of quartz) have had success\r\n-- running in dedicated mode, so only consider the above as a hint ;-)\r\n--\r\n\r\ndelete from Qrtz_Fired_Triggers;\r\ndelete from Qrtz_Simple_Triggers;\r\ndelete from Qrtz_Simprop_Triggers;\r\ndelete from Qrtz_Cron_Triggers;\r\ndelete from Qrtz_Blob_Triggers;\r\ndelete from Qrtz_Triggers;\r\ndelete from Qrtz_Job_Details;\r\ndelete from Qrtz_Calendars;\r\ndelete from Qrtz_Paused_Trigger_Grps;\r\ndelete from Qrtz_Locks;\r\ndelete from Qrtz_Scheduler_State;\r\n\r\ndrop table Qrtz_Calendars;\r\ndrop table Qrtz_Fired_Triggers;\r\ndrop table Qrtz_Blob_Triggers;\r\ndrop table Qrtz_Cron_Triggers;\r\ndrop table Qrtz_Simple_Triggers;\r\ndrop table Qrtz_Simprop_Triggers;\r\ndrop table Qrtz_Triggers;\r\ndrop table Qrtz_Job_Details;\r\ndrop table Qrtz_Paused_Trigger_Grps;\r\ndrop table Qrtz_Locks;\r\ndrop table Qrtz_Scheduler_State;\r\n\r\n\r\ncreate table Qrtz_Job_Details\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Job_Name  varchar2(200) not null,\r\n    Job_Group varchar2(200) not null,\r\n    Description varchar2(250) null,\r\n    Job_Class_Name   varchar2(250) not null, \r\n    Is_Durable varchar2(1) not null,\r\n    Is_Nonconcurrent varchar2(1) not null,\r\n    Is_Update_Data varchar2(1) not null,\r\n    Requests_Recovery varchar2(1) not null,\r\n    Job_Data blob null,\r\n    constraint Qrtz_Job_Details_pk primary key (Sched_Name,Job_Name,Job_Group)\r\n);\r\ncreate table Qrtz_Triggers\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Job_Name  varchar2(200) not null, \r\n    Job_Group varchar2(200) not null,\r\n    Description varchar2(250) null,\r\n    Next_Fire_Time number(19) null,\r\n    Prev_Fire_Time number(19) null,\r\n    Priority number(13) null,\r\n    Trigger_State varchar2(16) not null,\r\n    Trigger_Type varchar2(8) not null,\r\n    Start_Time number(19) not null,\r\n    End_Time number(19) null,\r\n    Calendar_Name varchar2(200) null,\r\n    Misfire_Instr number(2) null,\r\n    Job_Data blob null,\r\n    constraint Qrtz_Triggers_pk primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    constraint qrtz_trigger_to_jobs_fk foreign key (Sched_Name,Job_Name,Job_Group) \r\n      references Qrtz_Job_Details(Sched_Name,Job_Name,Job_Group) \r\n);\r\ncreate table Qrtz_Simple_Triggers\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Repeat_Count number(7) not null,\r\n    Repeat_Interval number(12) not null,\r\n    Times_Triggered number(10) not null,\r\n    constraint qrtz_simple_trig_pk primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    constraint qrtz_simple_trig_to_trig_fk foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n\treferences Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\n);\r\ncreate table Qrtz_Cron_Triggers\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Cron_Expression varchar2(120) not null,\r\n    Time_Zone_Id varchar2(80),\r\n    constraint qrtz_cron_trig_pk primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    constraint qrtz_cron_trig_to_trig_fk foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n      references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\n);\r\ncreate table Qrtz_Simprop_Triggers\r\n  (          \r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Str_Prop_1 varchar2(512) null,\r\n    Str_Prop_2 varchar2(512) null,\r\n    Str_Prop_3 varchar2(512) null,\r\n    Int_Prop_1 number(10) null,\r\n    Int_Prop_2 number(10) null,\r\n    Long_Prop_1 number(19) null,\r\n    Long_Prop_2 number(19) null,\r\n    Dec_Prop_1 numeric(13,4) null,\r\n    Dec_Prop_2 numeric(13,4) null,\r\n    Bool_Prop_1 varchar2(1) null,\r\n    Bool_Prop_2 varchar2(1) null,\r\n    Time_Zone_Id varchar2(80) null,\r\n    constraint qrtz_simprop_trig_pk primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    constraint qrtz_simprop_trig_to_trig_fk foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n      references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\n);\r\ncreate table Qrtz_Blob_Triggers\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Blob_Data blob null,\r\n    constraint qrtz_blob_trig_pk primary key (Sched_Name,Trigger_Name,Trigger_Group),\r\n    constraint qrtz_blob_trig_to_trig_fk foreign key (Sched_Name,Trigger_Name,Trigger_Group) \r\n        references Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\n);\r\ncreate table Qrtz_Calendars\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Calendar_Name  varchar2(200) not null, \r\n    Calendar blob not null,\r\n    constraint Qrtz_Calendars_pk primary key (Sched_Name,Calendar_Name)\r\n);\r\ncreate table Qrtz_Paused_Trigger_Grps\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Trigger_Group  varchar2(200) not null, \r\n    constraint qrtz_paused_trig_grps_pk primary key (Sched_Name,Trigger_Group)\r\n);\r\ncreate table Qrtz_Fired_Triggers \r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    entry_id varchar2(140) not null,\r\n    Trigger_Name varchar2(200) not null,\r\n    Trigger_Group varchar2(200) not null,\r\n    Instance_Name varchar2(200) not null,\r\n    Fired_Time number(19) not null,\r\n    Sched_Time number(19) not null,\r\n\tPriority number(13) not null,\r\n    State varchar2(16) not null,\r\n    Job_Name varchar2(200) null,\r\n    Job_Group varchar2(200) null,\r\n    Is_Nonconcurrent varchar2(1) null,\r\n    Requests_Recovery varchar2(1) null,\r\n    constraint qrtz_fired_trigger_pk primary key (Sched_Name,entry_id)\r\n);\r\ncreate table Qrtz_Scheduler_State \r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Instance_Name varchar2(200) not null,\r\n    Last_Checkin_Time number(19) not null,\r\n    Checkin_Interval number(13) not null,\r\n    constraint Qrtz_Scheduler_State_pk primary key (Sched_Name,Instance_Name)\r\n);\r\ncreate table Qrtz_Locks\r\n  (\r\n    Sched_Name varchar2(120) not null,\r\n    Lock_Name  varchar2(40) not null, \r\n    constraint Qrtz_Locks_pk primary key (Sched_Name,Lock_Name)\r\n);\r\n\r\ncreate index idx_qrtz_j_req_recovery on Qrtz_Job_Details(Sched_Name,Requests_Recovery);\r\ncreate index idx_qrtz_j_grp on Qrtz_Job_Details(Sched_Name,Job_Group);\r\n\r\ncreate index idx_qrtz_t_j on Qrtz_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_t_jg on Qrtz_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_t_c on Qrtz_Triggers(Sched_Name,Calendar_Name);\r\ncreate index idx_qrtz_t_g on Qrtz_Triggers(Sched_Name,Trigger_Group);\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Sched_Name,Trigger_State);\r\ncreate index idx_qrtz_t_n_state on Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_n_g_state on Qrtz_Triggers(Sched_Name,Trigger_Group,Trigger_State);\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Sched_Name,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Sched_Name,Trigger_State,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time);\r\ncreate index idx_qrtz_t_nft_st_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_State);\r\ncreate index idx_qrtz_t_nft_st_misfire_grp on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_Group,Trigger_State);\r\n\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Sched_Name,Instance_Name);\r\ncreate index idx_qrtz_ft_inst_job_req_rcvry on Qrtz_Fired_Triggers(Sched_Name,Instance_Name,Requests_Recovery);\r\ncreate index idx_qrtz_ft_j_g on Qrtz_Fired_Triggers(Sched_Name,Job_Name,Job_Group);\r\ncreate index idx_qrtz_ft_jg on Qrtz_Fired_Triggers(Sched_Name,Job_Group);\r\ncreate index idx_qrtz_ft_t_g on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group);\r\ncreate index idx_qrtz_ft_tg on Qrtz_Fired_Triggers(Sched_Name,Trigger_Group);\r\n\r\n\r\n";
            string sqlserver = "-- this script is for sql server and azure sql\r\n\r\nuse [enter_db_name_here]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Triggers_Qrtz_Job_Details]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Triggers] drop constraint fk_Qrtz_Triggers_Qrtz_Job_Details\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Cron_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Cron_Triggers] drop constraint fk_Qrtz_Cron_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Simple_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Simple_Triggers] drop constraint fk_Qrtz_Simple_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Simprop_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Simprop_Triggers] drop constraint fk_Qrtz_Simprop_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif  exists (select * from sys.foreign_keys where object_id = object_id(n'[dbo].[fk_qrtz_job_listeners_Qrtz_Job_Details]') and parent_object_id = object_id(n'[dbo].[qrtz_job_listeners]'))\r\nalter table [dbo].[qrtz_job_listeners] drop constraint [fk_qrtz_job_listeners_Qrtz_Job_Details]\r\n\r\nif  exists (select * from sys.foreign_keys where object_id = object_id(n'[dbo].[fk_qrtz_trigger_listeners_Qrtz_Triggers]') and parent_object_id = object_id(n'[dbo].[qrtz_trigger_listeners]'))\r\nalter table [dbo].[qrtz_trigger_listeners] drop constraint [fk_qrtz_trigger_listeners_Qrtz_Triggers]\r\n\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Calendars]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Calendars]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Cron_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Cron_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Blob_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Blob_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Fired_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Fired_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Paused_Trigger_Grps]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Paused_Trigger_Grps]\r\ngo\r\n\r\nif  exists (select * from sys.objects where object_id = object_id(n'[dbo].[qrtz_job_listeners]') and type in (n'u'))\r\ndrop table [dbo].[qrtz_job_listeners]\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Scheduler_State]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Scheduler_State]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Locks]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Locks]\r\ngo\r\nif  exists (select * from sys.objects where object_id = object_id(n'[dbo].[qrtz_trigger_listeners]') and type in (n'u'))\r\ndrop table [dbo].[qrtz_trigger_listeners]\r\n\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Job_Details]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Job_Details]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Simple_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Simple_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Simprop_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].Qrtz_Simprop_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Triggers]\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Calendars] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Calendar_Name] [nvarchar] (200)  not null ,\r\n  [Calendar] [varbinary](max) not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Cron_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Cron_Expression] [nvarchar] (120)  not null ,\r\n  [Time_Zone_Id] [nvarchar] (80) \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Fired_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [entry_id] [nvarchar] (140)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Instance_Name] [nvarchar] (200)  not null ,\r\n  [Fired_Time] [bigint] not null ,\r\n  [Sched_Time] [bigint] not null ,\r\n  [Priority] [integer] not null ,\r\n  [State] [nvarchar] (16)  not null,\r\n  [Job_Name] [nvarchar] (150)  null ,\r\n  [Job_Group] [nvarchar] (150)  null ,\r\n  [Is_Nonconcurrent] bit  null ,\r\n  [Requests_Recovery] bit  null \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Paused_Trigger_Grps] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Scheduler_State] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Instance_Name] [nvarchar] (200)  not null ,\r\n  [Last_Checkin_Time] [bigint] not null ,\r\n  [Checkin_Interval] [bigint] not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Locks] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Lock_Name] [nvarchar] (40)  not null \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Job_Details] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Job_Name] [nvarchar] (150)  not null ,\r\n  [Job_Group] [nvarchar] (150)  not null ,\r\n  [Description] [nvarchar] (250) null ,\r\n  [Job_Class_Name] [nvarchar] (250)  not null ,\r\n  [Is_Durable] bit  not null ,\r\n  [Is_Nonconcurrent] bit  not null ,\r\n  [Is_Update_Data] bit  not null ,\r\n  [Requests_Recovery] bit  not null ,\r\n  [Job_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Simple_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Repeat_Count] [integer] not null ,\r\n  [Repeat_Interval] [bigint] not null ,\r\n  [Times_Triggered] [integer] not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Simprop_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Str_Prop_1] [nvarchar] (512) null,\r\n  [Str_Prop_2] [nvarchar] (512) null,\r\n  [Str_Prop_3] [nvarchar] (512) null,\r\n  [Int_Prop_1] [int] null,\r\n  [Int_Prop_2] [int] null,\r\n  [Long_Prop_1] [bigint] null,\r\n  [Long_Prop_2] [bigint] null,\r\n  [Dec_Prop_1] [numeric] (13,4) null,\r\n  [Dec_Prop_2] [numeric] (13,4) null,\r\n  [Bool_Prop_1] bit null,\r\n  [Bool_Prop_2] bit null,\r\n  [Time_Zone_Id] [nvarchar] (80) null \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Blob_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Blob_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Job_Name] [nvarchar] (150)  not null ,\r\n  [Job_Group] [nvarchar] (150)  not null ,\r\n  [Description] [nvarchar] (250) null ,\r\n  [Next_Fire_Time] [bigint] null ,\r\n  [Prev_Fire_Time] [bigint] null ,\r\n  [Priority] [integer] null ,\r\n  [Trigger_State] [nvarchar] (16)  not null ,\r\n  [Trigger_Type] [nvarchar] (8)  not null ,\r\n  [Start_Time] [bigint] not null ,\r\n  [End_Time] [bigint] null ,\r\n  [Calendar_Name] [nvarchar] (200)  null ,\r\n  [Misfire_Instr] [integer] null ,\r\n  [Job_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Calendars] with nocheck add\r\n  constraint [pk_Qrtz_Calendars] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Calendar_Name]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Cron_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Cron_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Fired_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Fired_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [entry_id]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Paused_Trigger_Grps] with nocheck add\r\n  constraint [pk_Qrtz_Paused_Trigger_Grps] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Scheduler_State] with nocheck add\r\n  constraint [pk_Qrtz_Scheduler_State] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Instance_Name]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Locks] with nocheck add\r\n  constraint [pk_Qrtz_Locks] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Lock_Name]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Job_Details] with nocheck add\r\n  constraint [pk_Qrtz_Job_Details] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simple_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Simple_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simprop_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Simprop_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].Qrtz_Blob_Triggers with nocheck add\r\n  constraint [pk_Qrtz_Blob_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Cron_Triggers] add\r\n  constraint [fk_Qrtz_Cron_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simple_Triggers] add\r\n  constraint [fk_Qrtz_Simple_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simprop_Triggers] add\r\n  constraint [fk_Qrtz_Simprop_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n\t[Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Triggers] add\r\n  constraint [fk_Qrtz_Triggers_Qrtz_Job_Details] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  ) references [dbo].[Qrtz_Job_Details] (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  )\r\ngo\r\n\r\ncreate index idx_qrtz_t_j on Qrtz_Triggers(Sched_Name,Job_Name,Job_Group)\r\ncreate index idx_qrtz_t_jg on Qrtz_Triggers(Sched_Name,Job_Group)\r\ncreate index idx_qrtz_t_c on Qrtz_Triggers(Sched_Name,Calendar_Name)\r\ncreate index idx_qrtz_t_g on Qrtz_Triggers(Sched_Name,Trigger_Group)\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Sched_Name,Trigger_State)\r\ncreate index idx_qrtz_t_n_state on Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group,Trigger_State)\r\ncreate index idx_qrtz_t_n_g_state on Qrtz_Triggers(Sched_Name,Trigger_Group,Trigger_State)\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Sched_Name,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Sched_Name,Trigger_State,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_st_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_State)\r\ncreate index idx_qrtz_t_nft_st_misfire_grp on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_Group,Trigger_State)\r\n\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Sched_Name,Instance_Name)\r\ncreate index idx_qrtz_ft_inst_job_req_rcvry on Qrtz_Fired_Triggers(Sched_Name,Instance_Name,Requests_Recovery)\r\ncreate index idx_qrtz_ft_j_g on Qrtz_Fired_Triggers(Sched_Name,Job_Name,Job_Group)\r\ncreate index idx_qrtz_ft_jg on Qrtz_Fired_Triggers(Sched_Name,Job_Group)\r\ncreate index idx_qrtz_ft_t_g on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\ncreate index idx_qrtz_ft_tg on Qrtz_Fired_Triggers(Sched_Name,Trigger_Group)\r\ngo\r\n";
            string sqlserverMOT = "-- this script is for:\r\n   -- 64-bit enterprise, developer, or evaluation edition of sql server 2014\r\n   -- sql server 2016 rtm (pre-sp1) you need enterprise, developer, or evaluation edition.\r\n   -- sql server 2016 sp1 (or later), any edition. \r\n\r\nuse [master];\r\ngo\r\n\r\n-- note: modify database, path, filegroup, and file names as required\r\nalter database [enter_db_name_here] add filegroup [memoryoptimizeddata] contains memory_optimized_data\r\ngo\r\nalter database [enter_db_name_here] add file ( name = n'memoryoptimizeddata', filename = n'[enter_path_here]\\memoryoptimizeddata' ) to filegroup [memoryoptimizeddata]\r\ngo\r\nalter database [enter_db_name_here] set memory_optimized_elevate_to_snapshot = on\r\ngo\r\nalter database [enter_db_name_here] set read_committed_snapshot on with no_wait\r\ngo\r\nalter database [enter_db_name_here] set allow_snapshot_isolation on\r\ngo\r\n\r\nuse [enter_db_name_here];\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Triggers_Qrtz_Job_Details]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Triggers] drop constraint fk_Qrtz_Triggers_Qrtz_Job_Details\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Cron_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Cron_Triggers] drop constraint fk_Qrtz_Cron_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Simple_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Simple_Triggers] drop constraint fk_Qrtz_Simple_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[fk_Qrtz_Simprop_Triggers_Qrtz_Triggers]') and objectproperty(id, n'isforeignkey') = 1)\r\nalter table [dbo].[Qrtz_Simprop_Triggers] drop constraint fk_Qrtz_Simprop_Triggers_Qrtz_Triggers\r\ngo\r\n\r\nif  exists (select * from sys.foreign_keys where object_id = object_id(n'[dbo].[fk_qrtz_job_listeners_Qrtz_Job_Details]') and parent_object_id = object_id(n'[dbo].[qrtz_job_listeners]'))\r\nalter table [dbo].[qrtz_job_listeners] drop constraint [fk_qrtz_job_listeners_Qrtz_Job_Details]\r\n\r\nif  exists (select * from sys.foreign_keys where object_id = object_id(n'[dbo].[fk_qrtz_trigger_listeners_Qrtz_Triggers]') and parent_object_id = object_id(n'[dbo].[qrtz_trigger_listeners]'))\r\nalter table [dbo].[qrtz_trigger_listeners] drop constraint [fk_qrtz_trigger_listeners_Qrtz_Triggers]\r\n\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Calendars]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Calendars]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Cron_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Cron_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Blob_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Blob_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Fired_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Fired_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Paused_Trigger_Grps]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Paused_Trigger_Grps]\r\ngo\r\n\r\nif  exists (select * from sys.objects where object_id = object_id(n'[dbo].[qrtz_job_listeners]') and type in (n'u'))\r\ndrop table [dbo].[qrtz_job_listeners]\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Scheduler_State]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Scheduler_State]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Locks]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Locks]\r\ngo\r\nif  exists (select * from sys.objects where object_id = object_id(n'[dbo].[qrtz_trigger_listeners]') and type in (n'u'))\r\ndrop table [dbo].[qrtz_trigger_listeners]\r\n\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Job_Details]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Job_Details]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Simple_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Simple_Triggers]\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Simprop_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].Qrtz_Simprop_Triggers\r\ngo\r\n\r\nif exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[Qrtz_Triggers]') and objectproperty(id, n'isusertable') = 1)\r\ndrop table [dbo].[Qrtz_Triggers]\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Calendars] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Calendar_Name] [nvarchar] (200)  not null ,\r\n  [Calendar] [varbinary](max) not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Cron_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Cron_Expression] [nvarchar] (120)  not null ,\r\n  [Time_Zone_Id] [nvarchar] (80)\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Fired_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [entry_id] [nvarchar] (140)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Instance_Name] [nvarchar] (200)  not null ,\r\n  [Fired_Time] [bigint] not null ,\r\n  [Sched_Time] [bigint] not null ,\r\n  [Priority] [integer] not null ,\r\n  [State] [nvarchar] (16)  not null,\r\n  [Job_Name] [nvarchar] (150)  null ,\r\n  [Job_Group] [nvarchar] (150)  null ,\r\n  [Is_Nonconcurrent] bit  null ,\r\n  [Requests_Recovery] bit  null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Paused_Trigger_Grps] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Scheduler_State] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Instance_Name] [nvarchar] (200)  not null ,\r\n  [Last_Checkin_Time] [bigint] not null ,\r\n  [Checkin_Interval] [bigint] not null\r\n)\r\ngo\r\n\r\n-- note: review bucket_count and modify as required\r\ncreate table [dbo].[Qrtz_Locks]\r\n(\r\n  [id] [uniqueidentifier] primary key nonclustered hash ( [id] ) with ( bucket_count = 1000 ) default ( newsequentialid() ) not null,\r\n  [Sched_Name] [nvarchar] ( 120 ) collate latin1_general_100_bin2 not null,\r\n  [Lock_Name] [nvarchar] ( 40 ) collate latin1_general_100_bin2 not null,\r\n) with ( memory_optimized = on, durability = schema_and_data );\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Job_Details] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Job_Name] [nvarchar] (150)  not null ,\r\n  [Job_Group] [nvarchar] (150)  not null ,\r\n  [Description] [nvarchar] (250) null ,\r\n  [Job_Class_Name] [nvarchar] (250)  not null ,\r\n  [Is_Durable] bit  not null ,\r\n  [Is_Nonconcurrent] bit  not null ,\r\n  [Is_Update_Data] bit  not null ,\r\n  [Requests_Recovery] bit  not null ,\r\n  [Job_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Simple_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Repeat_Count] [integer] not null ,\r\n  [Repeat_Interval] [bigint] not null ,\r\n  [Times_Triggered] [integer] not null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Simprop_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Str_Prop_1] [nvarchar] (512) null,\r\n  [Str_Prop_2] [nvarchar] (512) null,\r\n  [Str_Prop_3] [nvarchar] (512) null,\r\n  [Int_Prop_1] [int] null,\r\n  [Int_Prop_2] [int] null,\r\n  [Long_Prop_1] [bigint] null,\r\n  [Long_Prop_2] [bigint] null,\r\n  [Dec_Prop_1] [numeric] (13,4) null,\r\n  [Dec_Prop_2] [numeric] (13,4) null,\r\n  [Bool_Prop_1] bit null,\r\n  [Bool_Prop_2] bit null,\r\n  [Time_Zone_Id] [nvarchar] (80) null \r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Blob_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Blob_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\ncreate table [dbo].[Qrtz_Triggers] (\r\n  [Sched_Name] [nvarchar] (120)  not null ,\r\n  [Trigger_Name] [nvarchar] (150)  not null ,\r\n  [Trigger_Group] [nvarchar] (150)  not null ,\r\n  [Job_Name] [nvarchar] (150)  not null ,\r\n  [Job_Group] [nvarchar] (150)  not null ,\r\n  [Description] [nvarchar] (250) null ,\r\n  [Next_Fire_Time] [bigint] null ,\r\n  [Prev_Fire_Time] [bigint] null ,\r\n  [Priority] [integer] null ,\r\n  [Trigger_State] [nvarchar] (16)  not null ,\r\n  [Trigger_Type] [nvarchar] (8)  not null ,\r\n  [Start_Time] [bigint] not null ,\r\n  [End_Time] [bigint] null ,\r\n  [Calendar_Name] [nvarchar] (200)  null ,\r\n  [Misfire_Instr] [integer] null ,\r\n  [Job_Data] [varbinary](max) null\r\n)\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Calendars] with nocheck add\r\n  constraint [pk_Qrtz_Calendars] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Calendar_Name]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Cron_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Cron_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Fired_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Fired_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [entry_id]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Paused_Trigger_Grps] with nocheck add\r\n  constraint [pk_Qrtz_Paused_Trigger_Grps] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Scheduler_State] with nocheck add\r\n  constraint [pk_Qrtz_Scheduler_State] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Instance_Name]\r\n  )\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Job_Details] with nocheck add\r\n  constraint [pk_Qrtz_Job_Details] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simple_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Simple_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simprop_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Simprop_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Triggers] with nocheck add\r\n  constraint [pk_Qrtz_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].Qrtz_Blob_Triggers with nocheck add\r\n  constraint [pk_Qrtz_Blob_Triggers] primary key  clustered\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) \r\ngo\r\n\r\nalter table [dbo].[Qrtz_Cron_Triggers] add\r\n  constraint [fk_Qrtz_Cron_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simple_Triggers] add\r\n  constraint [fk_Qrtz_Simple_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Simprop_Triggers] add\r\n  constraint [fk_Qrtz_Simprop_Triggers_Qrtz_Triggers] foreign key\r\n  (\r\n\t[Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) references [dbo].[Qrtz_Triggers] (\r\n    [Sched_Name],\r\n    [Trigger_Name],\r\n    [Trigger_Group]\r\n  ) on delete cascade\r\ngo\r\n\r\nalter table [dbo].[Qrtz_Triggers] add\r\n  constraint [fk_Qrtz_Triggers_Qrtz_Job_Details] foreign key\r\n  (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  ) references [dbo].[Qrtz_Job_Details] (\r\n    [Sched_Name],\r\n    [Job_Name],\r\n    [Job_Group]\r\n  )\r\ngo\r\n\r\ncreate index idx_qrtz_t_j on Qrtz_Triggers(Sched_Name,Job_Name,Job_Group)\r\ncreate index idx_qrtz_t_jg on Qrtz_Triggers(Sched_Name,Job_Group)\r\ncreate index idx_qrtz_t_c on Qrtz_Triggers(Sched_Name,Calendar_Name)\r\ncreate index idx_qrtz_t_g on Qrtz_Triggers(Sched_Name,Trigger_Group)\r\ncreate index idx_qrtz_t_state on Qrtz_Triggers(Sched_Name,Trigger_State)\r\ncreate index idx_qrtz_t_n_state on Qrtz_Triggers(Sched_Name,Trigger_Name,Trigger_Group,Trigger_State)\r\ncreate index idx_qrtz_t_n_g_state on Qrtz_Triggers(Sched_Name,Trigger_Group,Trigger_State)\r\ncreate index idx_qrtz_t_next_fire_time on Qrtz_Triggers(Sched_Name,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_st on Qrtz_Triggers(Sched_Name,Trigger_State,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time)\r\ncreate index idx_qrtz_t_nft_st_misfire on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_State)\r\ncreate index idx_qrtz_t_nft_st_misfire_grp on Qrtz_Triggers(Sched_Name,Misfire_Instr,Next_Fire_Time,Trigger_Group,Trigger_State)\r\n\r\ncreate index idx_qrtz_ft_trig_inst_name on Qrtz_Fired_Triggers(Sched_Name,Instance_Name)\r\ncreate index idx_qrtz_ft_inst_job_req_rcvry on Qrtz_Fired_Triggers(Sched_Name,Instance_Name,Requests_Recovery)\r\ncreate index idx_qrtz_ft_j_g on Qrtz_Fired_Triggers(Sched_Name,Job_Name,Job_Group)\r\ncreate index idx_qrtz_ft_jg on Qrtz_Fired_Triggers(Sched_Name,Job_Group)\r\ncreate index idx_qrtz_ft_t_g on Qrtz_Fired_Triggers(Sched_Name,Trigger_Name,Trigger_Group)\r\ncreate index idx_qrtz_ft_tg on Qrtz_Fired_Triggers(Sched_Name,Trigger_Group)\r\ngo\r\n";
            Dictionary<string, string> keyValuePairs = new Dictionary<string, string> {
                {"mysql",mysql },
                {"sqlite",sqlite },
                {"postgres",postgres },
                {"firebird",firebird },
                {"oracle",oracle },
                {"sqlserver",sqlserver },
                {"sqlserverMOT",sqlserverMOT }
            };
            return keyValuePairs[key]?.ToString();
        }
    }
}
